<template>
    <div class="systemMessage-wrapper">
        <IHeader class="header" back="true" title="系统消息"></IHeader>
        <list class="list" v-if="itemList && itemList.length > 0" @loadmore="loadmore">
            <cell class="cell" v-for="item in itemList" :key="item.id">
                <text class="time">{{item.createTime}}</text>
                <text class="word">{{item.content}}</text>
            </cell>
        </list>
        <text class="noData" v-if="!itemList || itemList.length <= 0">暂无数据</text>
        <!--loading-->
        <wxc-loading :show="loadingShow" :need-mask="needMask"></wxc-loading>
    </div>
</template>

<script>
import IHeader from '@/components/header'
import { WxcLoading } from 'weex-ui'
import { getMessageCenter } from '@/api/user'
export default {
  name: 'systemMessage',
  data () {
    return {
      needMask: true, // 显示蒙版
      loadingShow: false, // loading
      pageNo: 1,
      pageSize: 10,
      itemList: [], // 数据列表
      loadEnd: false
    }
  },
  mounted () {
    this.getDataList()
  },
  methods: {
    getDataList () {
      const that = this
      let params = {
        pageNo: that.pageNo,
        pageSize: that.pageSize,
        moduleType: 1
      }
      that.$api.get(getMessageCenter, params, (res) => {
        if (res.data.records.length <= 0) {
          that.loadEnd = true
          return
        }
        that.itemList = that.itemList.concat(res.data.records)
      }, () => {}, true)
    },
    loadmore () {
      const that = this
      if (that.loadEnd) {
        return
      }
      that.pageNo++
      that.getDataList()
    }
  },
  components: {
    IHeader,
    WxcLoading
  }
}
</script>

<style scoped>
    .list {
        min-height: 500px;
        margin-top: 88px;
        padding-left: 50px;
        padding-right: 50px;
    }
    .cell {
        padding-top: 24px;
        padding-bottom: 8px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .time {
        width: 350px;
        height: 44px;
        color: #f5f5f5;
        line-height: 44px;
        font-size: 26px;
        text-align: center;
        background-color: #cecece;
        border-radius: 8px;
    }
    .word {
        width: 650px;
        margin-top: 44px;
        color: #868686;
        font-size: 26px;
        line-height: 36px;
    }
    .noData {
        margin-top: 120px;
        font-size: 30px;
        color: #464646;
        text-align: center;
    }
</style>
